package com.zscat.mallplus.qsg.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zscat.mallplus.qsg.CostDuration;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface QsgCostDurationMapper extends BaseMapper<CostDuration> {

    @Select("SELECT member_name as memberName,SUM(TIMESTAMPDIFF(HOUR,start_time,end_time)) AS totalDuration FROM dms_order WHERE order_status IN (2,7) GROUP BY member_id ORDER BY totalDuration DESC LIMIT 10")
    List<CostDuration> selectTop10Users();

    @Select("SELECT member_name as memberName,SUM(TIMESTAMPDIFF(HOUR,start_time,end_time)) AS totalDuration FROM dms_order WHERE order_status IN (2,7) and create_datetime >= #{startTime} and create_datetime <= #{endTime} and store_id = #{storeId} GROUP BY member_id ORDER BY totalDuration DESC LIMIT 10")
    List<CostDuration> selectTop10UsersForMonth(@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("storeId") Integer storeId);
}
